﻿using System;
using System.Collections.ObjectModel;


namespace advadev.CanOpen
{

    /// <summary>
    /// Must be implemented from each transfer
    /// </summary>
    public interface ITransfer
    {

        /// <summary>
        /// When implemented, gets a flag indicating whether the transfer is
        /// complete (after sending the pending send messages)
        /// </summary>
        bool TransferComplete
        {
            get;
        }

        /// <summary>
        /// When implemented, gets the abort code (null for successful
        /// transfers)
        /// </summary>
        CanOpenAbortCode AbortCode
        {
            get;
        }

        /// <summary>
        /// When implemented, gets the pending send messages
        /// </summary>
        ReadOnlyCollection<CanOpenMessage> PendingSendMessages
        {
            get;
        }


        /// <summary>
        /// When implemented, starts the transfer
        /// </summary>
        void Start();

        /// <summary>
        /// When implemented, times out the transfer
        /// </summary>
        void TimeOut();

        /// <summary>
        /// When implemented, finalizes the transfer
        /// </summary>
        void FinalizeTransfer();

        /// <summary>
        /// When implemented, continues the transfer after sending messages
        /// </summary>
        void ContinueAfterSendingMessages();

        /// <summary>
        /// When implemented, processes the received message
        /// </summary>
        /// <param name="receivedCanOpenMessage">
        /// Received can open message
        /// </param>
        /// <returns>
        /// True, if the given can open message was related to this transfer,
        /// false otherwise
        /// </returns>
        bool ProcessReceivedMessage(CanOpenMessage receivedCanOpenMessage);

    }

}
